//
//  NewTongJiTableViewCell.m
//  wangzhe
//
//  Created by 李 佳伟 on 2018/3/10.
//  Copyright © 2018年 李 佳伟. All rights reserved.
//

#import "NewTongJiTableViewCell.h"
#import "JTCSM.h"
@interface NewTongJiTableViewCell (){
    UIImageView *titleImageV;
    UILabel *titleLabel;
    UIImageView *logoImageV;
    UILabel *userNameLabel;
    UILabel *dayLabel;
    UILabel *moneyLabel;
    UILabel *alertLabel;
}
@end

@implementation NewTongJiTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier tongJiCellType:(TongJiCellType)type  CellSata:(TongJiCellType)cellsate{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        CGFloat cellHeight = 60;
        CGFloat imagesize = 25;
        CGFloat logoImageSize = 40;
        CGFloat space = 20;
        if (type == ImageCellType) {
            titleImageV = [[UIImageView alloc]initWithFrame:CGRectMake(space, (cellHeight-imagesize*1.25925)/2, imagesize, imagesize*1.25925)];
            [self.contentView addSubview:titleImageV];
        }
        if (type == NumberCellType) {
            titleLabel = [UILabel initWithFrame:CGRectMake(space, (cellHeight-imagesize)/2, imagesize, imagesize) text:@"" font:12 textAlignment:NSTextAlignmentCenter texcolor:[df colorWithHexString:@"666666" alpha:1] backgroundColor:nil];
            [self.contentView addSubview:titleLabel];
        }
        
        logoImageV =[[UIImageView alloc]initWithFrame:CGRectMake(space+10+imagesize, (cellHeight-logoImageSize)/2, logoImageSize, logoImageSize)];
        logoImageV.image = [UIImage imageNamed:@"个人信息1_头像.png"];
        [self.contentView addSubview:logoImageV];
        
        if (cellsate == DoubleLabelCellType) {
            
            CGRect rect = [df labelHeightWithContent:@"测试数据" width:1000 font:14];
            CGRect rect1 = [df labelHeightWithContent:@"测试数据" width:1000 font:12];
            CGFloat changetop = 8;
            CGFloat top = (cellHeight -rect.size.height-rect1.size.height-changetop)/2;
            userNameLabel = [UILabel initWithFrame:CGRectMake(KVIEW_X(logoImageV)+10, top, KSCREENWidth, rect.size.height) text:@"测试数据" font:14 textAlignment:NSTextAlignmentLeft texcolor:[df colorWithHexString:@"333333" alpha:1] backgroundColor:nil];
            [self.contentView addSubview:userNameLabel];
            
            moneyLabel = [UILabel initWithFrame:CGRectMake(KVIEW_X(logoImageV)+10, KVIEW_Y(userNameLabel)+changetop, KSCREENWidth, rect1.size.height) text:@"349843.00" font:12 textAlignment:NSTextAlignmentLeft texcolor:[df colorWithHexString:@"999999" alpha:1] backgroundColor:nil];
            [self.contentView addSubview:moneyLabel];
            
            dayLabel = [UILabel initWithFrame:CGRectMake(KSCREENWidth-space-200, top, 200, rect.size.height) text:@"123445天" font:14 textAlignment:NSTextAlignmentRight texcolor:[df colorWithHexString:@"ff1818" alpha:1] backgroundColor:nil];
            [self.contentView addSubview:dayLabel];
            alertLabel = [UILabel initWithFrame:CGRectMake(KSCREENWidth-space-200, KVIEW_Y(dayLabel)+changetop, 200, rect1.size.height) text:@"红包奖励" font:11 textAlignment:NSTextAlignmentRight texcolor:[df colorWithHexString:@"999999" alpha:1] backgroundColor:nil];
            [self.contentView addSubview:alertLabel];
            
        }else{
            userNameLabel = [UILabel initWithFrame:CGRectMake(KVIEW_X(logoImageV)+10, 0, KSCREENWidth, cellHeight) text:@"测试数据" font:14 textAlignment:NSTextAlignmentLeft texcolor:[df colorWithHexString:@"333333" alpha:1] backgroundColor:nil];
            [self.contentView addSubview:userNameLabel];
            
            dayLabel = [UILabel initWithFrame:CGRectMake(KSCREENWidth-space-200, 0, 200, cellHeight) text:@"123445天" font:14 textAlignment:NSTextAlignmentRight texcolor:[df colorWithHexString:@"ff1818" alpha:1] backgroundColor:nil];
            [self.contentView addSubview:dayLabel];
        }
       
        
        
    }
    
    return self;
    
    
}

- (void)setValueWithModel:(NSIndexPath *)index{
    switch (index.row) {
        case 0:
            titleImageV.image = [UIImage imageNamed:@"第一.png"];
            break;
        case 1:
            titleImageV.image = [UIImage imageNamed:@"第二.png"];
            break;
        case 2:
            titleImageV.image = [UIImage imageNamed:@"第三.png"];
            break;
            
        default:
            break;
    }
    titleLabel.text = [NSString stringWithFormat:@"%ld",(long)index.row];
    index.row%2==0?(self.contentView.backgroundColor = [UIColor whiteColor]):(self.contentView.backgroundColor = RGBACOLOR(241, 241, 241, 1));
}

@end
